﻿<%@ Page Title="Diskusní fórum" Language="C#" MasterPageFile="~/Pages/Site.Master" AutoEventWireup="true" CodeBehind="Detail.aspx.cs" Inherits="Altairis.FluffyCloud.WebCore.Pages.Forum.Detail" %>
<asp:Content ContentPlaceHolderID="Main" runat="server">
    <asp:FormView ID="HeaderFormView" runat="server" ItemType="Altairis.FluffyCloud.Data.Topic" SelectMethod="HeaderFormView_GetItem" OnItemCommand="HeaderFormView_ItemCommand">
        <EmptyDataTemplate>
            <h1>Diskusní fórum</h1>
            <p>Takové diskusní fórum neexistuje.</p>
        </EmptyDataTemplate>
        <ItemTemplate>
            <div class="iconbar">
                <asp:HyperLink runat="server" Text="RSS feed" CssClass="rss" ToolTip="RSS feed" NavigateUrl='<%# this.GetRouteUrl("MyTopicFeed", new { securityCode = this.Context.GetUserData().SecurityCode, topicId = Item.TopicId }) %>' />
                <asp:HyperLink runat="server" Text="Přidat do oblíbených" CssClass="bookmark-add" ToolTip="Přidat do oblíbených" NavigateUrl='<%# this.GetRouteUrl("MyHome", null) + "?bookmark-add=" + Item.TopicId %>' Visible="<%# !this.IsBookmarked %>" />
                <asp:HyperLink runat="server" Text="Smazat z oblíbených" CssClass="bookmark-delete" ToolTip="Smazat z oblíbených" NavigateUrl='<%# this.GetRouteUrl("MyHome", null) + "?bookmark-delete=" + Item.TopicId %>' Visible="<%# this.IsBookmarked %>" />
            </div>
            <h1><%#: Item.Name %></h1>
            <ul class="topicinfo">
                <li class="category"><%#: Item.TopicCategory.Name %></li>
                <li class="owner">
                    <asp:HyperLink runat="server" NavigateUrl='<%# this.GetRouteUrl("UserProfile", new { username = Item.UserName }) %>' Text="<%#: Item.UserName %>" />
                </li>
                <li class="datecreated"><%#: Item.DateCreated.ToLocalDisplayFormat() %></li>
                <asp:PlaceHolder runat="server" Visible="<%# Item.UserName.Equals(this.User.Identity.Name, StringComparison.CurrentCultureIgnoreCase) %>">
                    <li class="owneronly">
                        <asp:HyperLink NavigateUrl="<%$ RouteUrl: RouteName=ForumSettings %>" runat="server" Text="Nastavení" />
                    </li>
                    <li class="owneronly">
                        <asp:HyperLink NavigateUrl="<%$ RouteUrl: RouteName=ForumAcl %>" runat="server" Text="Oprávnění" />
                    </li>
                </asp:PlaceHolder>
            </ul>
            <asp:PlaceHolder runat="server" Visible="<%# !Item.EvaluateTopicPermissionsForCurrentUser(TopicAclEntry.OperationRead) %>">
                <p>Do tohoto fóra nemáte přístup. Pokud ho chcete získat, kontaktujte vlastníka.</p>
                <div class="description">
                    <my:WikiMarkup runat="server" Text="<%# Item.PublicHeaderText %>" />
                </div>
            </asp:PlaceHolder>
            <asp:PlaceHolder runat="server" Visible="<%# Item.EvaluateTopicPermissionsForCurrentUser(TopicAclEntry.OperationRead) %>">
                <div class="description">
                    <my:WikiMarkup runat="server" Text="<%# Item.HeaderText %>" />
                </div>
                <asp:PlaceHolder runat="server" Visible="<%# Item.EvaluateTopicPermissionsForCurrentUser(TopicAclEntry.OperationPost) %>">
                    <div class="form">
                        <div>
                            <asp:TextBox ID="NewPostTextBox" runat="server" TextMode="MultiLine" Height="150px" data-exteditortype="wikimarkup" />
                            <asp:RequiredFieldValidator runat="server" ControlToValidate="NewPostTextBox" Display="None" ErrorMessage="Není zadán text příspěvku" ValidationGroup="NewPost" />
                        </div>
                        <asp:ValidationSummary runat="server" />
                        <div>
                            <asp:Button Text="Přidat zprávu" runat="server" CommandName="NewPost" ValidationGroup="NewPost" />
                        </div>
                    </div>
                </asp:PlaceHolder>
                <asp:ListView ID="PostsListView" runat="server" ItemType="Altairis.FluffyCloud.Data.TopicPost" DataKeyNames="TopicPostId" SelectMethod="PostsListView_GetData">
                    <LayoutTemplate>
                        <section class="postlist">
                            <asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
                            <footer>
                                <div class="left">
                                    <asp:HyperLink ID="LinkFirst" runat="server" Text="&#x25C0; nejnovější" />
                                    <asp:HyperLink ID="LinkPrevious" runat="server" Text="&#x25C0; novější" />
                                </div>
                                <div class="right">
                                    <asp:HyperLink ID="LinkNext" runat="server" Text="starší &#x25B6;" />
                                    <asp:HyperLink ID="LinkLast" runat="server" Text="nejstarší &#x25B6;" />
                                </div>
                                <asp:Literal ID="LiteralPagerInfo" runat="server" Text="celkem {2} příspěvků, stránka {3} z {4} " />
                            </footer>
                        </section>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <asp:PlaceHolder runat="server">
                            <article id="<%#: Item.TopicPostId %>" class="post">
                                <aside>
                                    <my:UserIcon runat="server" UserName="<%# Item.UserName %>" Size="50" NavigateUrl='<%# this.GetRouteUrl("MyUserMessages", new { username = Item.UserName }) %>' />
                                </aside>
                                <header>
                                    <div class="more">
                                        <asp:Label Text="nové" runat="server" CssClass="new" Visible="<%# Item.DateCreated> this.LastVisitDate %>" />
                                        <asp:Label Text="<%#: Item.DateCreated.ToLocalDisplayFormat() %>" runat="server" CssClass="date" />
                                        <asp:HyperLink runat="server" Text="smazat" NavigateUrl='<%# this.GetRouteUrl("ForumDetail", this.RouteData.Values) + "?delete=" + Item.TopicPostId.ToString("N") %>' Visible="<%# this.CanDeleteAll || (this.CanDeleteOwn && Item.UserName.Equals(this.User.Identity.Name, StringComparison.CurrentCultureIgnoreCase)) %>" data-confirm-prompt="Opravdu chcete tento příspěvek nevratně smazat?" />
                                        <asp:HyperLink runat="server" Text="upravit" NavigateUrl='<%# this.GetRouteUrl("ForumEditPost", new { topicid = Item.TopicId, postid = Item.TopicPostId.ToString("N") }) %>' Visible="<%# this.CanEditPosts && Item.UserName.Equals(this.User.Identity.Name, StringComparison.CurrentCultureIgnoreCase)  %>" />
                                    </div>
                                    <asp:HyperLink NavigateUrl='<%# this.GetRouteUrl("UserProfile", new { username = Item.UserName }) %>' Text="<%#: Item.UserName %>" runat="server" CssClass="username" />
                                    <asp:Label Text="<%#: Item.User.Comment %>" runat="server" CssClass="usercomment" />
                                </header>
                                <my:WikiMarkup runat="server" Text="<%# Item.Text %>" />
                            </article>
                        </asp:PlaceHolder>
                    </ItemTemplate>
                </asp:ListView>
                <altairis:DataPagerExtender runat="server" TargetControlID="PostsListView" PageSize="20" PageIndexSource="RouteParameter" FirstLinkID="LinkFirst" LastLinkID="LinkLast" NextLinkID="LinkNext" PreviousLinkID="LinkPrevious" InfoLabelID="LiteralPagerInfo" InactiveLinkMode="Disable" />
            </asp:PlaceHolder>
        </ItemTemplate>
    </asp:FormView>
</asp:Content>